package cn.wolfcode.mycat.controller;

import cn.wolfcode.mycat.domain.User;
import cn.wolfcode.mycat.mapper.UserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by wolfcode-lanxw
 */
@Slf4j
@RestController
@Api(value = "UserController服务", tags = "UserController服务")
public class UserController {
    @Autowired
    private UserMapper userMapper;
    
    @PostMapping("/user/save/{id}/{name}")
    @ApiOperation(value = "新增用户")
    public String save(@PathVariable("id") Long id, @PathVariable("name") String name){
    	User user = new User();
    	user.setId(id);
    	user.setName(name);
        userMapper.insert(user);
        return "保存成功";
    }
    @GetMapping("/user/list")
    @ApiOperation(value = "queryUserList")
    public List<User> list(){
        return userMapper.selectAll();
    }
}
